using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

namespace TimeSheet.includes
{
    /// <summary>
    /// Summary description for TimeSheetFormBase.
    /// </summary>
    public class TimeSheetFormBase : Page
    {
        public TimeSheetFormBase()
        {
        }

        protected virtual void ClearForm()
        {
            Trace.Write("Test", "Clearing Form");
            foreach (Control c in Controls)
            {
                Trace.Write("Test", c.GetType().ToString());
                if (c is HtmlForm)
                {
                    ClearControlCollection(((HtmlForm) c).Controls);
                }
            }
        }

        private void ClearControlCollection(ControlCollection controls)
        {
            foreach (Control c in controls)
            {
                if (c is TextBox)
                {
                    TextBox tb = (TextBox) c;
                    tb.Text = "";
                }
                if (c is CheckBox)
                {
                    CheckBox cb = (CheckBox) c;
                    cb.Checked = false;
                }
                if (c is DropDownList)
                {
                    DropDownList ddl = (DropDownList) c;
                    ddl.SelectedIndex = 0;
                }
            }
        }
    } //class
} //namespace